import java.util.ArrayDeque;
import java.util.Queue;

/**
 * @program: LeetCode
 * @description: LeetCode : 剑指 Offer II 042. 最近请求次数
 * @author: WXY
 * @create: 2022-12-31 14:13
 * @Version 1.0
 **/
public class offer_fourteen2_RecentCounter {
    class RecentCounter {
        Queue<Integer> queue;

        public RecentCounter() {
            queue = new ArrayDeque<>();
        }

        public int ping(int t) {
            queue.offer(t);
            while (queue.peek() < t - 3000) {
                queue.poll();
            }
            return queue.size();
        }
    }

}
